home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-05-01 | 47.3 KB | 1,341 lines | [TEXT/MPS ] |
- ;
- ;File PaletteWDEF.a
- ;--------------------------------------------------------------------------
- ;
- ; Window Definition Routine for MacApp floaters
- ;
- ; BUILD COMMANDS:
- ;
- ; Asm "PaletteWDEF.a"
- ; Link -rt WDEF=3 "PaletteWDEF.a.o" -o "Your File"
- ;
- ;
- ; This file contains the window definition procedure "WindoidProc",
- ; the "windoid" window type. It is a rectangular window with a title bar.
- ;
- ; 3/14/90 Added to the MacApp sources from the HyperCard sources. Thanks to HyperCard team,
- ; especially Kevin Calhoun.
-
- BLANKS ON
- STRING ASIS
- CASE OFF
-
- PRINT OFF
- INCLUDE 'SysEqu.a' ; <JKC 18May89>
- INCLUDE 'QuickEqu.a' ; <JKC 18May89>
- INCLUDE 'Traps.a' ; <JKC 18May89>
- INCLUDE 'ToolEqu.a' ; <JKC 18May89>
- PRINT ON
-
- WDEF3 MAIN EXPORT ; <JKC 18May89>
-
- ;
- ; FUNCTION WindoidProc(selector: INTEGER;
- ; window: WindowPtr,
- ; message: INTEGER;
- ; parameter: LongInt): LongInt
-
- LinkSize EQU -38
- ClpRgn EQU -38 ; our custom clip region
- IsColor EQU -34 ; do we have colorQD and toolbox? [boolean]
- Align EQU -33 ; a dead byte for IsColor
- SavBkCol EQU -32 ; saved wmgrCPort RGBBackColor (color only)
- SavFgCol EQU -26 ; saved wmgrCPort RGBForeColor (color only)
- AuxCPtr EQU -20 ; pointer to auxCTable (color only)
- AuxCTab EQU -16 ; handle to auxCTable (color only)
- TempRgn EQU -12 ; <18Oct85>
- WInfoRec EQU -8 ; <1Aug85>
- WAscent EQU -8 ; <1Aug85>
- WDescent EQU -6 ; <1Aug85>
- WHeight EQU -4 ; <1Aug85>
- WBoxDelta EQU -2 ; <1Aug85>
-
- message EQU 12 ; <C666/22Jan87> DAF
-
- hasZoom EQU 3 ; bit 3 is zoom bit <EHB 29Aug85>
- hasGrow EQU 2 ; bit 2 is grow bit <EHB 29Aug85>
- hasTallTBar EQU 1 ; bit 1 is tall title bar bit <JKC 7Jan90>
- toggleTBar EQU 0 ; bit 0 tells us whether to hilite/unhilite title bar <JKC 7Jan90>
-
- DocProc
- BRA.S DP1
-
- ; standard header
-
- DC.W 0 ; flags word
- DC.B 'WDEF' ; resource type
- DC.W 3 ; resource ID
- DC.W 2 ; version number
-
- DP1
- LINK A6,#LinkSize ; set up a stack frame to address parameters
- MOVEM.L D2-D7/A1-A4,-(SP) ; save work registers
-
- ; test if the message is in range
-
- CMP.W #wGIconMsg,message(A6) ; compare to highest value <C666/22Jan87> DAF
- BGT OORange ; skip it, it's too high <C666/22Jan87> DAF
- CMP.W #wDrawMsg,message(A6) ; compare to lowest value, too <C666/22Jan87> DAF
- BMI OORange ; <C666/22Jan87> DAF
-
-
- MOVE.L (A5),A0 ; get pointer to quickDraw globals <7Aug85>
- MOVE.L (A0),-(SP) ; save current port on stack <7Aug85>
-
- ; Determine type of system. We need to know if we have color QuickDraw and a color
- ; window manager port.
-
- CMP.W #$3FFF,ROM85 ; do we have color QD?
- SLS IsColor(A6) ; set boolean depending on color or B&W system
- BHI.S @BWSys ; no, this system has B&W QD
-
- ; when using the wmgrCPort, it is the defproc's responsibility to reconcile
- ; the wmgrPort and the wmgrCPort.
-
- BSR UpdateCPort ; compare and update wmgrPorts, also set WMgrCPort
-
- BRA.S @CommonSys ;
- @BWSys
- MOVE.L WMgrPort,-(SP) ; and set port to window manager port
- _SetPort ;
- @CommonSys
-
- ; get the font info for this font. Put the height of the title bar in D7 and wHeight(A6).
- ; put the distance of the top of the goaway box from the top of the bar in WBoxDelta(A6).
-
- LEA WInfoRec(A6),A3 ; point to our info rec <5Aug85>
- MOVE.W 18(A6),D6 ; get variant code <JKC 31Jul89>
- BTST #hasTallTBar,D6 ; does it have tall title bar? <JKC 31Jul89>
- BNE.S @1 ; => if so, skip to tall tbar stuff <JKC 31Jul89>
- MOVEQ #11,D7 ; fix title bar height at 11 pixels <JKC 31Jul89>
- MOVE.W D7,wHeight(A6) ; put title bar height here too <JKC 31Jul89>
- MOVE.W #0,WBoxDelta(A6) ; goAway delta is 2 pixels <JKC 31Jul89>
- BRA.S DoTempRgn ; skip the tall title bar stuff <JKC 31Jul89>
-
- @1 MOVE.L A3,-(SP) ; push a pointer <5Aug85>
- _GetFontInfo ; and get the font's info <5Aug85>
- MOVE.W (A3)+,D7 ; (rect inset by 1 when WAscent used) <5Aug85>
- ADD.W (A3)+,D7 ; add descent <5Aug85>
- ADDQ.W #4,D7 ; get the height <5Aug85>
- BSET #0,D7 ; make height odd for symmetry <5Aug85>
- MOVEQ #19,D1 ; get 19 <26Aug85>
- CMP.W D1,D7 ; force height to 19 min <26Aug85>
- BGE.S @3 ; => not a tiny font <5Aug85>
- SUB.W D7,D1 ; how much less than 19 is it? <26Aug85>
- LSR.W #1,D1 ; used for centering tiny fonts <26Aug85>
- ADD.W D1,WAscent(A6) ; make the ascent "bigger" <26Aug85>
- MOVEQ #19,D7 ; <5Aug85>
- @3 MOVE.W D7,(A3)+ ; WHeight = ascent+descent+2 <5Aug85>
- MOVE.W D7,D0 ; get height <EHB 29Aug85>
- SUB.W #13,D0 ; subtract height of box <5Aug85>
- LSR.W #1,D0 ; divide by 2 <5Aug85>
- MOVE.W D0,(A3) ; save delta to goAway box <5Aug85>
-
- DoTempRgn ; set up a temp region
-
- CLR.L -(SP) ; make room for result <EHB 18Oct85>
- _NewRgn ; get a new region <EHB 18Oct85>
- MOVE.L (SP)+,TempRgn(A6) ; and save in our frame <EHB 18Oct85>
- CLR.L -(SP) ; make room for result <JKC 26Sep89>
- _NewRgn ; get a new region <JKC 26Sep89>
- MOVE.L (SP)+,ClpRgn(A6) ; and save in our frame <JKC 26Sep89>
-
- ; save off the current port fore- & backcolors on color systems.
-
- TST.B IsColor(A6) ; is it a color system?
- BEQ.S @NoColor1 ; nope, so skip this
-
- PEA SavFgCol(A6) ; push a pointer to save area
- _GetForeColor ; get the current color
- PEA SavBkCol(A6) ;
- _GetBackColor ;
-
- ; also, find the auxWinRec and lock it down
-
- CLR.L -(SP) ; here's a space for the var handle
- CLR.W -(SP) ; function return here
- MOVE.L 14(A6),-(SP) ; push window ptr
- PEA 6(SP) ; a pointer to the space above
- _GetAuxWin ; find the auxrec
- ADDQ #2,SP ; pitch the boolean (it doesn't matter)
- MOVE.L (SP)+,A0 ; get the auxRecHandle
- MOVE.L (A0),A0 ; handle -> ptr
- MOVE.L awCTable(A0),A0 ; get the colortable handle <JKC 18May89>
- MOVE.L A0,AuxCTab(A6) ; save this handle
- _HLock ; lock the table down in memory
- MOVE.L (A0),AuxCPtr(A6) ; and get a pointer too!
-
- @NoColor1 ; END OF A COLOR-ONLY SECTION
-
- ; fetch the parameters into registers
-
- LEA 8(A6),A0 ; get ptr to first parameter
- MOVE.L (A0)+,D3 ; get param in D3
- MOVE.W (A0)+,D0 ; get message
- MOVE.L (A0)+,A3 ; get the window pointer
- MOVE.W (A0)+,D5 ; get the selector integer
- MOVE D5,D6 ; keep copy in D6
- AND #3,D5 ; ignore "inGrow" variant
- CLR.L (A0) ; clear out function result
-
- ; case out on the message number
-
- ADD D0,D0 ; double for word index
- LEA GoDocProc,A0 ; get jump table address
- ADD.W GODOCPROC(D0),A0 ; compute dispatch address
- JSR (A0)
-
- ; we're done -- restore registers and return to caller
-
- MOVE.L TempRgn(A6),-(SP) ; dispose of temp region <EHB 18Oct85>
- _DisposRgn ; <EHB 18Oct85>
- MOVE.L ClpRgn(A6),-(SP) ; dispose of clip region <JKC 26Sep89>
- _DisposRgn ; <JKC 26Sep89>
-
- TST.B IsColor(A6) ; are we on a color system?
- BEQ.S @NoColor2 ; if on B&W, then skip
-
- MOVE.L AuxCTab(A6),A0 ; get the colortable handle <DAF 15-Apr-86>
- _HUnlock ; release it <DAF 15-Apr-86>
-
- ; restore the fore- and backColors <C203/08Oct86> DAF
- PEA savBkCol(A6) ; pointer to RGBColor
- _RGBBackColor ;
- PEA savFgCol(A6) ; pointer to RGBColor
- _RGBForeColor ;
-
- @NoColor2 ; END OF A COLOR-ONLY SECTION
-
- _SetPort ; the old port is on top of stack <EHB 7Aug85>
- OORange ; 'Out Of Range, of course' <C666/22Jan87> DAF
- MOVEM.L (SP)+,D2-D7/A1-A4 ; restore work registers
- UNLK A6 ; unlink stack frame
- MOVE.L (SP)+,A0 ; get return address
- ADD #12,SP ; strip parameters
- JMP (A0) ; return to caller
-
- ; DocumentProc dispatch table -- entries must be long branches!
-
- GODOCPROC
- DC.W DrawDoc-GoDocProc ; draw is message #0
- DC.W HitDoc-GoDocProc ; hit test is message #1
- DC.W CalcDoc-GoDocProc ; calc test is message #2
- DC.W InitDoc-GoDocProc ; init is message #3
- DC.W DisposeDoc-GoDocProc ; dispose is message #4
- DC.W GrowDoc-GoDocProc ; grow message is #5
- DC.W DrawGIcon-GoDocProc ; draw grow icon is #6
-
-
- ; utility UpdateCPort
- ; This utility compares the pertinent fields of the wmgrPort and the wmgrCPort,
- ; updating the wmgrCPort as necessary to match the wmgrPort.
-
- UpdateCPort ; <C666/22Jan87> DAF
- MOVE.L WmgrCPort,-(SP) ; make the wmgrCPort the current port
- _SetPort ; set it
-
- MOVE.L WmgrPort,A0 ; get the wmgrPort addr
- MOVE.L WmgrCPort,A1 ; and the wmgrCPort too
-
- PEA bkPat(A0) ; push pointers to pattern for later
- PEA pnPat(A0) ;
-
- ; copy all fields from pnLoc to end of grafPort, excluding pnPixPat and fillPixPat
-
- LEA pnLoc(A0),A0 ; point at source
- LEA pnLoc(A1),A1 ; point at dest
- MOVE.L (A0)+,(A1)+ ; copy pnLoc
- MOVE.L (A0)+,(A1)+ ; copy pnSize
- MOVE.W (A0)+,(A1)+ ; copy pnMode
- ADDQ #8,A0 ; skip pnPat (aka, pnPixPat,fillPixPat)
- ADDQ #8,A1 ;
- MOVE.W #((portRec-pnVis)/2)-1,D0 ; set up a counter (long sized)
- @1
- MOVE.W (A0)+,(A1)+ ; copy it
- DBRA D0,@1 ; loop
-
- ; now set up the patterns in the wmgrCPort (which is thePort)
- ; the parameters were pushed before the copying loop above
-
- _PenPat
- _BackPat
-
- RTS ; <C666/22Jan87> DAF
-
- ; InitDoc is used to initialize our zoom size
-
- InitDoc BTST #hasZoom,D6 ; does it want a zoom box? <EHB 29Aug85>
- BEQ.S noZoom ; => nope, no zoom <EHB 29Aug85>
- CLR.B wZoom(A3) ; assume no zoom box <EHB 29Aug85>
- TST.W ROM85 ; running on new roms? <EHB 18Oct85>
- BMI.S noZoom ; => no, use default <EHB 18Oct85>
- MOVEQ #16,D0 ; space for 2 rects <EHB 29Aug85>
- _NewHandle ,CLEAR ; allocate the space <EHB 29Aug85>
- BNE.S noZoom ; => not able to get space <EHB 29Aug85>
-
- ; set default zoom data. Consists of 2 fields: SmallSize, BigSize: Rect
-
- ADDQ.B #1,wZoom(A3) ; set zoom flag to TRUE <EHB 29Aug85>
- MOVE.L A0,WDataHandle(A3) ; save handle to data <EHB 29Aug85>
- MOVE.L (A0),A4 ; point to data <EHB 29Aug85>
- ADDQ.W #8,A4 ; point to bigSize <EHB 29Aug85>
-
- ; get the size of the zoomed out window in global coordinates. To do this,
- ; pull the screen size from screenbits.bounds and indent a little.
-
- MOVE.L GrafGlobals(A5),A1 ; point to QuickDraw globals <EHB 29Aug85>
- MOVE.L Screenbits+Bounds(A1),(A4)+ ; get topLeft <EHB 29Aug85>
- MOVE.L Screenbits+Bounds+4(A1),(A4)+ ; get botRight <EHB 29Aug85>
- MOVEQ #3,D0 ; get indent <EHB 29Aug85>
- SUB.W D0,-(A4) ; indent right <EHB 29Aug85>
- SUB.W D0,-(A4) ; indent bottom <EHB 29Aug85>
- ADD.W D0,-(A4) ; indent left <EHB 29Aug85>
- ADD.W D0,-(A4) ; indent top <EHB 29Aug85>
- MOVE.W MBarHeight,D0 ; get menubar height <JKC 31Jul89>
- ADD.W D0,(A4) ; past menu bar <JKC 31Jul89>
- ADD.W D7,(A4) ; and past window title <EHB 29Aug85>
-
- MOVE.L (A0),A4 ; A4 = smallsize <EHB 29Aug85>
-
- ; get current size into rect in A4
-
- GetRect MOVE.L A4,-(SP) ; push address of rect <EHB 29Aug85>
- MOVE.L PortRect(A3),(A4) ; get topLeft (local) <EHB 29Aug85>
- MOVE.L PortRect+4(A3),4(A4) ; get botRight (local) <EHB 29Aug85>
- MOVE.L A3,A0 ; copy portPtr for PortToMap <C424/18Nov86> DAF
- BSR PortToMap ; get the rect pointer <C424/18Nov86> DAF
- MOVE.L Bounds(A0),-(SP) ; push offset locToGlob <EHB 29Aug85>
- NEG.W (SP) ; make offset positive <EHB 29Aug85>
- NEG.W 2(SP)
- _OffsetRect ; convert rect to global
- NoZoom RTS
-
- ; IsItSmall returns NE if the window has been resized or moved (NE if window "small")
- ; It updates smallsize if it has. (If tab, only move small window).
- ; Trashes A0,A1,A4
-
- IsItSmall SUBQ #8,SP ; make room for a rect <EHB 29Aug85>
- MOVE.L SP,A4 ; point to it <EHB 29Aug85>
- BSR.S GetRect ; A4 = curSize <EHB 29Aug85>
- MOVE.L wDataHandle(A3),A0 ; get data handle <EHB 29Aug85>
- MOVE.L (A0),A2 ; A2 = bigSize <EHB 29Aug85>
- ADDQ #8,A2
-
- ; the window is large if all corners are within 7 of their default positions
-
- BSR.S ChkPoint ; compare topleft <EHB 18Sep85>
- BNE.S IsSmall ; => not close enough <EHB 29Aug85>
- BSR.S ChkPoint ; compare botright <EHB 18Sep85>
- BEQ.S NotSmall ; => it's close enough <EHB 29Aug85>
- IsSmall MOVE.L wDataHandle(A3),A0 ; get data handle <EHB 29Aug85>
- MOVE.L (A0),A4 ; save window's current size <EHB 29Aug85>
- BSR.S GetRect ; get current size into A4 <EHB 29Aug85>
- SaySmall MOVEQ #1,D0 ; return NE! <EHB 29Aug85>
- NotSmall ADDQ #8,SP ; strip rect from stack <EHB 29Aug85>
- RTS
-
- ChkPoint MOVE.L (A2),-(SP) ; make point into a rect <EHB 18Sep85>
- MOVE.L (A2)+,-(SP) ; by pushing twice <EHB 18Sep85>
- MOVE.L SP,-(SP) ; and insetting by 7 <EHB 18Sep85>
- MOVE.L #$FFF9FFF9,-(SP) ; <EHB 18Sep85>
- _InsetRect ; <EHB 18Sep85>
- CLR.W -(SP) ; is cursize within 7 of <EHB 18Sep85>
- MOVE.L (A4)+,-(SP) ; that point? <EHB 18Sep85>
- PEA 6(SP) ; <EHB 18Sep85>
- _PtInRect ; <EHB 18Sep85>
- SUBQ.B #1,(SP) ; reverse sign of result <EHB 18Sep85>
- MOVE.B (SP)+,D0 ; <EHB 18Sep85>
- ADDQ #8,SP ; strip off the rect <EHB 18Sep85>
- RTS ; exit w/EQ if "Big" <EHB 18Sep85>
-
- ; IsThereZoom returns EQ if zoom not enabled
-
- IsThereZoom BTST #hasZoom,D6 ; zooming variant <EHB 29Aug85>
- BEQ.S IsNoZoom ; => no <EHB 29Aug85>
- TST.B wZoom(A3) ; did we get the handle? <EHB 29Aug85>
- IsNoZoom RTS ; EQ if no Zoom <EHB 29Aug85>
-
-
-
- ; DisposeDoc is called when the window is being closed. All we need to do is
- ; give back the handle we borrowed.
-
- DisposeDoc BSR.S IsThereZoom ; is there a zoom box? <EHB 29Aug85>
- BEQ.S InDisposed ; => no, we're done <EHB 29Aug85>
- MOVE.L wDataHandle(A3),A0 ; get handle to our data <EHB 29Aug85>
- _DisposHandle ; release it, ignoring errors <EHB 29Aug85>
- InDisposed RTS
-
-
-
- ; SetUpColor takes a window part identifier in D0, finds the corresponding
- ; part in the AuxWinTable (the part code is in the .value field) and returns
- ; a pointer to its RGB on the stack. If the requested part is not found,
- ; the first color table element is used (I'd use frameColor, but that might
- ; not be there!). Trashes A0/D0. ; rewritten <C177/25Sep86> DAF
-
- SetUpColor
- MOVE.L D1,-(SP) ; save a register
- MOVE.L AuxCPtr(A6),A0 ; get the color table pointer
- MOVE.W CTSize(A0),D1 ; get the color table size
- MULU #8,D1 ; convert to color table index
- LegalIndex
- CMP.W CTTable+value(A0,D1),D0 ; is this the one?
- BEQ.S FoundIt ; if equal, then done
- SUB.W #8,D1 ; try the previous one
- BGE.S LegalIndex ; loop while index positive
- MOVEQ #0,D1 ; OK, use the first one
- FoundIt
- LEA CTTable+rgb(A0,D1),A0 ; get the address of the color to use
- MOVE.L A0,D0 ; we'll need A0 in a second
- MOVE.L (SP)+,D1 ; restore the register
- MOVE.L (SP)+,A0 ; get the return address
- MOVE.L D0,-(SP) ; push the rgb addr on the stack
- JMP (A0) ; return to caller
-
-
- PORTTOMAP ; <C424/18Nov86> DAF
- ;----------------------------------------------------------
- ;
- ; Given a window pointer in A0, return the bitmap/pixmap pointer in A0
-
- ADDQ #PORTBITS,A0 ;POINT TO BITMAP/PIXMAP HANDLE
- TST ROWBYTES(A0) ;BITMAP OR PIXMAP HANDLE?
- BPL.S GOTBITMAP ;=>JUST A BITMAP
- MOVE.L BASEADDR(A0),A0 ;ELSE GET PORT'S PIXMAP HANDLE
- MOVE.L (A0),A0 ;GET PIXMAP POINTER
- GOTBITMAP RTS
-
-
-
- ; DrawDoc -- draw the document window. The windowPtr is in A3
-
- DrawDoc
- TST.B WVISIBLE(A3) ; is it visible?
- BEQ DoneDoc ; if not, don't do anything
-
- ; see if its a EORGoAway call and special case it
-
- CMP #wInGoAway,D3 ; is it a goAway call?
- BGE EorStuff ; if so, go handle it <EHB 29Aug85>
-
- _PenNormal ; we want the normal pen
-
- ; derive the titleBar rectangle from the structRgn and keep it in TempRect
-
- BSR BuildTBarRect
-
- ; draw the title bar
-
- TST.B IsColor(A6) ; is it color?
- BEQ.S @NoColor3 ; no, so skip this
-
- MOVE.W #wFrameColor,D0 ; color to set <C203/08Oct86> DAF
- BSR.S SetUpColor ; set it up <C203/08Oct86> DAF
- _RGBForeColor ; <C203/08Oct86> DAF
-
- MOVE.W #wTitleBarColor,D0 ; <C203/08Oct86> DAF
- BSR.S SetUpColor ; <C203/08Oct86> DAF
- _RGBBackColor ; <C203/08Oct86> DAF
-
- @NoColor3 ; END OF A COLOR-ONLY SECTION
-
- PEA TEMPRECT ; tempRect bounds the title bar
- MOVE.L (SP),-(SP) ; make another copy of tempRect pointer
- BTST #toggleTBar,D6 ; should we toggle the title bar? <JKC 20Sep89>
- BEQ.S @1 ; no, don't erase title bar <JKC 17Aug89>
- TST.B wHilited(A3) ; is it hilited?
- BNE.S @1 ; yes, don't erase title bar
- MOVE.L (SP),-(SP) ; copy for InsetRect <JKC 17Aug89>
- _EraseRect ; erase it <JKC 17Aug89>
- @1 _FrameRect ; frame the title bar
- MOVE.L OneOne,-(SP) ; push inset factor
- _InsetRect
-
- BTST #hasTallTBar,D6 ; does it have tall title bar? <JKC 31Jul89>
- BEQ.S CheckHilite ; => no, don't draw title string <JKC 31Jul89>
- BSR DoTitleString ; draw the centered Title
-
- ; To prevent title flicker, DoTitleString returns the left edge of the
- ; title in D3 and the right edge in D4. If the title bar needs to be
- ; highlighted, the highlighting is done in 2 sections, one on each side
- ; of the title.
-
- CheckHilite
- BTST #toggleTBar,D6 ; pay attention to the hilite state? <JKC 20Sep89>
- BEQ.S DoHilite ; no, do hilite no matter what <JKC 20Sep89>
- TST.B wHilited(A3) ; is it hilited?
- BEQ DrawBody ; => go draw the frame
-
- DoHilite
- TST.B IsColor(A6) ; is it color?
- BEQ.S @NoColor4 ; no, so skip this
-
- MOVE.W #wTitleBarColor,D0 ; set up colors <C203/08Oct86> DAF
- BSR SetUpColor ;
- _RGBBackColor ;
-
- MOVE.W #wHiliteColor,D0 ;
- BSR SetUpColor ;
- _RGBForeColor ; <C203/08Oct86> DAF
- @NoColor4 ; END OF A COLOR-ONLY SECTION
-
- BTST #hasTallTBar,D6 ; does it have tall title bar? <JKC 31Jul89>
- BEQ.S @2 ; => no, fill entire title bar <JKC 31Jul89>
-
- MOVE.W TempRect+Right,-(SP) ; save right of TempRect
- MOVE.W D3,TempRect+Right ; new right = title left
-
- ; used A4 instead of A0 to save a couple o'bytes (EHB)
-
- @2 MOVE.L TempRect,D0 ; get topLeft
- AND.L #$00070007,D0 ; only use mod 8
- MOVE.L (A5),A4 ; get globals, save in A4
- MOVE.L D0,PatAlign(A4) ; set up patAlign
- PEA TempRect ; fill this rect
- BTST #hasTallTBar,D6 ; does it have tall title bar? <stm 16oct89>
- BEQ.S @7 ; => no, use regular pat <stm 16oct89>
- PEA AltHilitePattern ; => yes, use alternate pat <stm 16oct89>
- BRA.S @6 ; <stm 16oct89>
- @7 PEA HilitePattern ; push the pattern address
- @6 _FillRect ; fill with the pattern
-
- BTST #hasTallTBar,D6 ; does it have tall title bar? <JKC 31Jul89>
- BEQ.S ClrPatAln ; => no, draw the go away button <JKC 31Jul89>
-
- BSR IsThereZoom ; is zooming allowed? (was .S) <EHB 18-Oct-85>
- BEQ.S @1 ; => no, use current d4 <EHB 18-Oct-85>
- MOVE.W (SP),D0 ; else get right edge of box <EHB 18-Oct-85>
- SUB.W #26,D0 ; how much room is there? <EHB 18-Oct-85>
- CMP.W D4,D0 ; need at least 26 pixels <EHB 18-Oct-85>
- BGE.S @1 ; => got 'em, use current d4 <EHB 18-Oct-85>
- MOVE.W D0,D4 ; else use right-26 <EHB 18-Oct-85>
-
- @1 MOVE.W (SP)+,TempRect+Right ; restore right of title box
- MOVE.W D4,TempRect+Left ; set new left of title box
- PEA TempRect ; fill this rect
- PEA HilitePattern ; push the pattern address
- MOVE.W TempRect+top,D0 ; get top <stm 16oct89>
- SWAP D0 ; into high word <stm 16oct89>
- MOVE.W TempRect+right,D0 ; get right into low word <stm 16oct89>
- AND.L #$00070007,D0 ; only use mod 8 <stm 16oct89>
- MOVE.L D0,PatAlign(A4) ; set up patAlign <stm 16oct89>
- _FillRect
-
- ClrPatAln CLR.L PatAlign(A4)
-
- ; plot the goAway button
-
- DoGoAway
- TST.B WGoAway(A3) ; is there a goaway button?
- BEQ.S DoZoom ; => if not, try for zoom <EHB 29Aug85>
-
- BTST #hasTallTBar,D6 ; does it have tall title bar? <JKC 31Jul89>
- BNE.S @3 ; => yes, plot big go away <JKC 31Jul89>
- BSR DrawSmallGoAway ; plot small go away box <JKC 31Jul89>
- BRA.S DoZoom ; skip big go away <JKC 31Jul89>
-
- @3 BSR BuildTBarRect
- LEA GoAwayData,A1 ; get the goAway symbol
- MOVEQ #srcCopy,D0 ; plot in srcCopy mode <EHB 29Aug85>
- BSR PlotGoAway
-
- DoZoom BSR IsThereZoom ; is there a zoom box? <EHB 29Aug85>
- BEQ.S DrawBody ; => no, draw window frame <EHB 29Aug85>
-
- BSR.S BuildTBarRect ; build a title bar rect <EHB 29Aug85>
-
- BTST #hasTallTBar,D6 ; does it have tall title bar? <JKC 31Jul89>
- BNE.S @4 ; => yes, plot big zoom box <JKC 31Jul89>
- BSR DrawSmallZoom ; plot small zoom box <JKC 31Jul89>
- BRA.S DrawBody ; small title bar <JKC 31Jul89>
-
- @4 MOVE.W TempRect+Right,D0 ; <JKC 25May89>
- MOVE.W TempRect+Left,D4 ; <JKC 25May89>
- SUB.W D4,D0 ; <JKC 25May89>
-
- LEA ZoomData,A1 ; get the zoom data <stm 16oct89>
- MOVEQ #srcCopy,D0 ; plot in srcCopy mode <EHB 29Aug85>
- BSR PlotZoom ; and plot the symbol <EHB 29Aug85>
-
- DrawBody MOVE.L OneOne,D4 ; constant for shadowing
-
- ; frame the body of the window
-
- DrawFrame
- TST.B IsColor(A6) ; is it color?
- BEQ.S @NoColor5 ; no, so skip this section
-
- MOVE.L #wFrameColor,D0 ; set up colors <C203/08Oct86> DAF
- BSR SetUpColor ; <C203/08Oct86> DAF
- _RGBForeColor ; <C203/08Oct86> DAF
- MOVE.L #wContentColor,D0 ; set up background too for variant 1 <CXXX/21Jan87> DAF
- BSR SetUpColor ; <CXXX/21Jan87> DAF
- _RGBBackColor ; <CXXX/21Jan87> DAF
- @NoColor5 ; END OF A COLOR-ONLY SECTION
-
- MOVE.L STRUCTRGN(A3),A0 ; get region handle
- MOVE.L (A0),A0 ; get region ptr
- LEA RGNBBOX(A0),A4 ; point A4 at the bounding box
- SUB D4,Bottom(A4) ; inset the bottom (ignore shadow)
- SUB D4,Right(A4) ; inset the right to ignore shadow
- MOVE.L A4,-(SP) ; push bounding box
- _FrameRect ; frame the body
-
- ; draw the drop shadow
-
- BSR PaintDropShadow ; paint the drop shadow
-
- MOVE.L STRUCTRGN(A3),A4 ; get region handle again, for safety <S369/25Jan88> DAF
- MOVE.L (A4),A4 ; get region ptr <S369/25Jan88> DAF
- LEA RGNBBOX(A4),A4 ; point A4 at the bounding box <S369/25Jan88> DAF
-
- ADD D4,Bottom(A4)
- ADD D4,Right(A4)
- DoneDoc
- RTS
-
- HilitePattern ; <JKC 25May89>
- DC.W $00AA,$00AA,$00AA,$00AA
-
- AltHilitePattern ; <JKC 25May89>
- DC.W $0055,$0055,$0055,$0055
-
-
- ; BuildTBarRect builds a rectangle enclosing the titleBar in TempRect
-
- BuildTBarRect
- LEA TEMPRECT,A0 ; get pointer to tempRect
- MOVE.L STRUCTRGN(A3),A1 ; get structure region handle
- MOVE.L (A1),A1 ; get strucRgn pointer
- ADDQ #RGNBBOX,A1 ; point A1 at the bounding box
- MOVE.L (A1)+,(A0) ; copy bounding box into tempRect
- MOVE.L (A1),4(A0)
-
- ; make bottom := top + WHeight
-
- MOVE Top(A0),D0 ; get top
- ADD.W D7,D0 ; add precomputed height <29Aug85>
- MOVE D0,Bottom(A0) ; update bottom
- SUBQ #1,Right(A0) ; inset right
- RTS ; return to caller
-
- ; decide which icon needs hiliting
-
- EORStuff BEQ.S EORGoAway ; => it's the goAway <EHB 29Aug85>
- BSR IsThereZoom ; should we do zoom? <EHB 29Aug85>
- BEQ.S NoGo ; => no <EHB 29Aug85>
-
- ; EORZoom hilites/unhilites the zoom button. Falls into PlotZoom
-
- EORZoom BTST #hasTallTBar,D6 ; does it have tall title bar? <JKC 31Jul89>
- BNE.S @1 ; => if so, skip to tall tbar stuff <JKC 31Jul89>
- BRA.S InvertSmallZoom
-
- @1 BSR.S BuildTBarRect ; build the bounding rect <EHB 29Aug85>
-
- LEA ZoomData+32,A1 ; get the zoom data <EHB 29Aug85>
-
- MOVEQ #srcXOR,D0 ; set EOR as the plot mode <EHB 29Aug85>
-
- PlotZoom LEA TempRect,A0 ; start from titlebar rect <EHB 29Aug85>
- MOVE right(A0),left(A0) ; left := right-22 <EHB 03Nov85>
- MOVEQ #-22,D1 ; <EHB 03Nov85>
- BRA.S PlotIt ; use common code to plot it <EHB 29Aug85>
-
- ; EORGoAway hilites/unhilites the goAway button. It falls through into PlotGoAway
-
- EorGoAway
- BTST #hasTallTBar,D6 ; does it have tall title bar? <JKC 31Jul89>
- BNE.S @2 ; => if so, skip to tall tbar stuff <JKC 31Jul89>
- BRA.S InvertSmallGoAway
- @2 BSR.S BuildTBarRect ; build the bounding rect
- LEA GoAwayData+32,A1 ; get the bitMap
- MOVEQ #srcXOR,D0 ; set EOR as the plot mode
-
- ; PlotGoAway plots the goAway button. A1 holds the symbol, D1 the plotting mode
-
- PlotGoAway
- ; make Temprect into a 16x16 square for our little bitmap
-
- LEA TempRect,A0 ; point to temprect <5Aug85>
- MOVEQ #6,D1 ; add margin to left <5Aug85>
-
- PlotIt ADD.W D1,left(A0) ; add offset to left <29Aug85>
- MOVE.W WBoxDelta(A6),D1 ; get offset from top to GABox <5Aug85>
- ADD.W D1,(A0) ; add offset to top <5Aug85>
- SUBQ.W #1,(A0) ; align bitmap <5Aug85>
- MOVE.L (A0)+,(A0) ; bottom/right = top/left <5Aug85>
- MOVEQ #16,D1 ; get a constant <5Aug85>
- ADD.W D1,(A0)+ ; Bottom = top + 16 <5Aug85>
- ADD.W D1,(A0) ; Right = Left + 16 <5Aug85>
-
- MOVE.L #$00100010,D1
- BSR PlotSymbol ; plot it in tempRect
- NoGo RTS
-
- InvertSmallGoAway
- BSR.S BuildSmallGoAway
- BSR.S InsetInvert
- RTS
-
- DrawSmallGoAway
- BSR.S BuildSmallGoAway ; get rect of goAway in TempRect <JKC 31Jul89>
- BSR.S EraseInsetFrame
- RTS
-
- BuildSmallGoAway
- BSR BuildTBarRect
- BSR.S InsetByOneOne
- LEA TempRect,A0 ; point to temprect <JKC 31Jul89>
- ADD.W #6,Left(A0) ; left is fixed at 6 from left edge <JKC 31Jul89>
- MOVE.W Left(A0),D2 ; save left of TempRect <JKC 31Jul89>
- ADD.W #9,D2 ; new right = left + 9 <JKC 31Jul89>
- MOVE.W D2,Right(A0) ; new right of TempRect <JKC 31Jul89>
- RTS
-
- InvertSmallZoom
- BSR.S BuildSmallZoom
- BSR.S InsetInvert
- RTS
-
- DrawSmallZoom
- BSR.S BuildSmallZoom ; get rect of zoom in TempRect <JKC 31Jul89>
- BSR.S EraseInsetFrame
- BSR.S BuildSmallZoom
- BSR.S InsetByOneOne
- LEA TempRect,A0
- SUB.W #3,Right(A0)
- SUB.W #3,Bottom(A0)
- MOVE.L A0,-(SP)
- _FrameRect
- RTS
-
- BuildSmallZoom
- BSR BuildTBarRect
- BSR.S InsetByOneOne
- LEA TempRect,A0 ; point to temprect <JKC 31Jul89>
- SUB.W #6,Right(A0) ; right is fixed at 6 from right edge <JKC 31Jul89>
- MOVE.W Right(A0),D2 ; save right of TempRect <JKC 31Jul89>
- SUB.W #9,D2 ; new left = right - 9 <JKC 31Jul89>
- MOVE.W D2,Left(A0) ; new left of TempRect <JKC 31Jul89>
- RTS
-
- InsetInvert
- BSR.S InsetByOneOne
- PEA TempRect ; push address of TempRect <JKC 31Jul89>
- _InverRect ; and invert it <JKC 31Jul89>
- RTS
-
- EraseInsetFrame
- PEA TempRect ; push address of TempRect <JKC 31Jul89>
- MOVE.L (SP),-(SP) ; make another copy of tempRect pointer <JKC 31Jul89>
- _EraseRect ; erase the area around the box <JKC 31Jul89>
- BSR.S InsetByOneOne
- _FrameRect ; frame the go away box <JKC 31Jul89>
- RTS
-
- InsetByOneOne
- PEA TempRect
- MOVE.L OneOne,-(SP) ; push inset factor <JKC 31Jul89>
- _InsetRect
- RTS
-
- ; DoTitleString is the common code that draws the title centered in tempRect. Warning --
- ; it trashes D3. On exit, the left edge of the title's box is in D3 and
- ; the right edge is in D4.
-
- DoTitleString
-
- ; compute indent factor based on GoAwayButton state
-
- @1 MOVE.W TempRect+Right,D4 ; get right into D4 <EHB 18-Oct-85>
- MOVE.W D4,D3 ; <EHB 18-Oct-85>
- SUB.W TempRect+Left,D3 ; compute width
- SUB.W wTitleWidth(A3),D3 ; compute extra x
- ASR.W #1,D3 ; divide by 2
-
- ; if the string is too long, position left edge
-
- MOVEQ #2,D0 ; start title at x = 2 <16-May-85 EHB>
- TST.B WGoAway(A3) ; is there a go away button <16-May-85 EHB>
- BEQ.S @2 ; skip if there's not <16-May-85 EHB>
- MOVEQ #32,D0 ; start title at x = 32 <16-May-85 EHB>
- @2 CMP.W D0,D3 ; to left of x? <16-May-85 EHB>
- BGE.S @3 ; => no, D3 is ok <16-May-85 EHB>
- MOVE.W D0,D3
- @3
- ADD.W TempRect+Left,D3 ; compute x position
- MOVE.W D4,-(SP) ; save right across clip <EHB 18-Oct-85>
- BSR IsThereZoom ; is there a zoom box? <EHB 18-Oct-85>
- BEQ.S @4 ; => no, edge ok <EHB 18-Oct-85>
- SUB.W #32,D4 ; get default right edge <EHB 18-Oct-85>
- @4
- ; set clip to d3..d4
-
- MOVE.W D4,TempRect+Right ; set right for clipping <EHB 18-Oct-85>
- _OpenRgn ; open our clip region <JKC 26Sep89>
- PEA TempRect ; point to tempRect <JKC 26Sep89>
- _FrameRect ; frame title area <JKC 26Sep89>
- MOVE.L ClpRgn(A6),-(SP) ; get our clip region <JKC 26Sep89>
- _CloseRgn ; close it <JKC 26Sep89>
-
- MOVE.L (A5),A0 ; get globals <EHB 18-Oct-85>
- MOVE.L (A0),A0 ; get port <EHB 18-Oct-85>
- MOVE.L ClipRgn(A0),-(SP) ; and the rect region <EHB 18-Oct-85>
- MOVE.L ClpRgn(A6),-(SP) ; get our clip region <JKC 26Sep89>
- MOVE.L (SP),-(SP) ; and use clip as dest <EHB 18-Oct-85>
- _SectRgn ; get the intersection <EHB 18-Oct-85>
-
- MOVE.W (SP)+,TempRect+Right ; restore tempRect <EHB 18-Oct-85>
-
- MOVE.W D3,-(SP) ; push left for MoveTo
- MOVE.W TempRect+Top,D0 ; get top <EHB 5Aug85>
- ADD.W WAscent(A6),D0 ; move down to baseline <EHB 5Aug85>
- ADDQ.W #1,D0 ; leave 2 pixels white space <EHB 7Aug85>
- MOVE.W D0,-(SP) ; push baseline <EHB 5Aug85>
- _MoveTo
-
- TST.B IsColor(A6) ; is it on a color system?
- BEQ.S @NoColor6
-
- MOVE.W #wTitleBarColor,D0 ; set up drawing colors
- BSR SetUpColor ;
- _RGBBackColor
- MOVE.W #wTextColor,D0 ;
- BSR SetUpColor ;
- _RGBForeColor ;
-
- MOVE.W #srcOR,-(SP) ; set the mode to source OR <C407/16Nov86> DAF
- _TextMode ; <C407/16Nov86> DAF
- @NoColor6 ; END OF A COLOR ONLY SECTION
-
- ; now calculate the size of the clear area needed for the title
- ; (only used if the window is highlighted).
-
- MOVE.W D3,D0 ; left in D3, calc right in D0
- SUBQ #6,D3 ; indent to the left
- ADD.W wTitleWidth(A3),D0 ; add in the length <EHB 18-Oct-85>
- CMP.W D4,D0 ; was title longer than space? <EHB 18-Oct-85>
- BGE.S @5 ; => yes, use D4 <EHB 18-Oct-85>
- MOVE.W D0,D4 ; <EHB 18-Oct-85>
- @5 ADD.W #6,D4 ; indent on right <EHB 18-Oct-85>
-
- MOVE.W TempRect+Left,-(SP) ; save left of TempRect <JKC 20Sep89>
- MOVE.W D3,TempRect+Left ; new left = title box left <JKC 20Sep89>
- MOVE.W TempRect+Right,-(SP) ; save right of TempRect <JKC 20Sep89>
- MOVE.W D4,TempRect+Right ; new right = title box right <JKC 20Sep89>
- PEA TempRect ; get title box rect <JKC 20Sep89>
- _EraseRect ; erase it <JKC 20Sep89>
- MOVE.W (SP)+,TempRect+Right ; restore right of TempRect <JKC 20Sep89>
- MOVE.W (SP)+,TempRect+Left ; restore left of TempRect <JKC 20Sep89>
-
- MOVE.L TempRgn(A6),-(SP) ; get our temp region <EHB 18-Oct-85>
- _GetClip ; and save for restore <EHB 18-Oct-85>
- MOVE.L ClpRgn(A6),-(SP) ; push the custom clip <JKC 26Sep89>
- _SetClip ; and set it <JKC 26Sep89>
-
- MOVE.L wTitleHandle(A3),A0 ; get titleHandle
- _HLock ; lock the title down <C491/08Dec86> DAF
- MOVE.L (A0),-(SP) ; push title pointer
- _DrawString ; draw it
- MOVE.L wTitleHandle(A3),A0 ; get the handle again <C491/08Dec86> DAF
- _HUnlock ; release it <C491/08Dec86> DAF
-
- MOVE.L TempRgn(A6),-(SP) ; push the old clip <EHB 18-Oct-85>
- _SetClip ; and restore it <EHB 18-Oct-85>
-
- RTS ; Left in D3, right in D4
-
-
- ; Snazzy new zoom data <JKC 25May89>
-
- ZoomData DC.W $5555,$0000,$3FF9,$2088 ; <stm 16oct89>
- DC.W $2089,$2088,$2089,$2088
- DC.W $3F89,$2008,$2009,$2008
- DC.W $3FF9,$0000,$5555,$0000
-
- ; starburst mask
- DC.W $0000,$0000,$0000,$0180
- DC.W $09A0,$05C0,$0080,$1CF0
- DC.W $1F80,$0540,$0920,$0100
- DC.W $0000,$0000,$0000,$0000
-
-
- ; BitMap for default GoAway button
-
- GoAwayData
-
- ; This is the goAway Data <JKC 25May89>
-
- DC.W $AAAA,$0000,$9FFC,$1004
- DC.W $9004,$1004,$9004,$1004
- DC.W $9004,$1004,$9004,$1004
- DC.W $9FFC,$0000,$AAAA,$0000
-
- ; starburst mask
-
- DC.W $0000,$0000,$0000,$0080
- DC.W $0490,$02A0,$0000,$0E38
- DC.W $0000,$02A0,$0490,$0080
- DC.W $0000,$0000,$0000,$0000
-
-
- ; Mask for goAway button (concentric squares)
-
- ; .WORD $0000,$0000,$0000,$0000
- ; .WORD $0FE0,$0820,$0BA0,$0AA0
- ; .WORD $0BA0,$0820,$0FE0,$0000
- ; .WORD $0000,$0000,$0000,$0000
-
- ; HitDoc -- perform a hit test on the document. On entry, D3 contains the mousePoint
- ; in global coordinates while A3 holds the window pointer
-
- HitDoc
- CLR.W -(SP) ; make room for function result
- MOVE.L D3,-(SP) ; push the mouse point
- MOVE.L CONTRGN(A3),-(SP) ; push content region handle
- _PtInRgn ; is the point in the content region?
- TST.B (SP)+ ; well, is it?
- BEQ.S NotInContent ; if not, go check out drag region
-
- ; it's in the content region -- see if it's in the grow icon area
-
- BTST #hasGrow,D6 ; inGrow enabled? <EHB 29Aug85>
- BGT.S justContent ; if not, skip
-
- TST.B wHilited(A3) ; is it active?
- BEQ.S justContent ; if not, it cant be in grow
-
- MOVE.L ContRgn(A3),A0 ; get region handle
- MOVE.L (A0),A0 ; get region ptr
- MOVE.L RgnBBox+botRight(A0),D0 ; get bottom left of content
-
- ; first consider the x coordinate <16-May-85 EHB>
-
- MOVEQ #14,D4 ; keep 14 in a register to save code
-
- SUB D4,D0 ; offset x by 14
- CMP D0,D3 ; if <, just in content
- BLT.S justContent
-
- ; its within range on x so try y
-
- SWAP D0
- SUB D4,D0 ; check out y dimension
- SWAP D3
- CMP D0,D3 ; compare y coordinates
- BLT.S justContent
-
- MOVEQ #wInGrow,D0 ; flag in grow Icon
- BRA DoneHitDoc
-
- ; the point is in the content region so return a '1'
-
- justContent
- MOVEQ #wInContent,D0 ; return in content
- BRA DoneHitDoc ; go store function result and return
-
- ; its not in the content -- see if its in the dragRgn (content extended by titleBar)
-
- NotInContent
-
- BSR BuildTBarRect ; get the title bar rect into A0 <EHB 21-Oct-85>
- CLR.W -(SP) ; make room for function result
- MOVE.L D3,-(SP) ; push the mouse point
- MOVE.L A0,-(SP) ; and push the rect <EHB 21-Oct-85>
- _PtInRect ; is the point in the title bar?
-
- TST.B (SP)+ ; examine result
- BEQ DoneHit1 ; if not, return 0 (do nothing)
-
-
- BTST #toggleTBar,D6 ; does the hilite state matter? <JKC 27Sep89>
- BEQ.S @1 ; no, test for goAway and zoom <JKC 27Sep89>
- TST.B wHilited(A3) ; is it hilited?
- BEQ ItsInDrag ; if not, can't be in GoAway
-
- ; test vertical for goAway and Zoom since they're the same
-
- @1 MOVE.L D3,D0 ; check vertical <EHB 29Aug85>
- SWAP D0 ; which is high word of D3 <EHB 29Aug85>
- MOVE.L A3,A0 ; convert the pointer if its a pixmap <C424/18Nov86> DAF
- BSR PortToMap ; convert <C424/18Nov86> DAF
- ADD.W Bounds+Top(A0),D0 ; convert to local <EHB 29Aug85>
- SUB.W PortRect+Top(A3),D0 ; compensate for origin <EHB 29Aug85>
-
- ADD.W WBoxDelta(A6),D0 ; below box? <5Aug85>
- BPL.S ItsInDrag ; => yes <5Aug85>
- ADD.W #11,D0 ; in box? <5Aug85>
- BMI.S ItsInDrag ; => no <5Aug85>
-
- TST.B WGoAway(A3) ; is there a goAway button?
- BEQ.S HitZoom ; => no, hit-test zoom <EHB 29Aug85>
-
- MOVE.L D3,D0 ; get mousePt
- ADD Bounds+Left(A0),D0 ; convert to local (A0 still valid) <C424/18Nov86> DAF
- SUB PortRect+Left(A3),D0 ; compensate for origin
- CMP #18,D0 ; is it too far right for
- ; either big or small? <JKC 31Jul89>
- BGT.S HitZoom ; if so, it's in drag <EHB 29Aug85>
- BTST #hasTallTBar,D6 ; does it have tall title bar? <JKC 31Jul89>
- BNE.S @2 ; => yes, test left > 7 <JKC 31Jul89>
- CMP #16,D0 ; is it too far right? <JKC 31Jul89>
- BGT.S HitZoom ; if so, its in drag <EHB 29Aug85>
- BRA.S @3 ; it's in small goAway <JKC 31Jul89>
- @2 SUBQ.W #8,D0 ; it must be at least 7
- ; to be in big goAway
- BMI.S ItsInDrag
-
- ; its in the goAway button so signal it
-
- @3 MOVEQ #wInGoAway,D0
- BRA.S DoneHitDoc
-
- HitZoom BSR IsThereZoom ; is zooming permitted? <EHB 29Aug85>
- BEQ.S ItsInDrag ; => not in these here parts <EHB 29Aug85>
-
- MOVE.W D3,D0 ; get mousePt <EHB 29Aug85>
- MOVE.L A3,A0 ; convert the pointer if its a pixmap <C424/18Nov86> DAF
- BSR PortToMap ; convert <C424/18Nov86> DAF
- ADD.W Bounds+Left(A0),D0 ; convert to local <EHB 29Aug85>
- SUB.W PortRect+Right(A3),D0 ; make right edge = 0 <EHB 29Aug85>
- CMP.W #-19,D0 ; too far left for either
- ; big or small title bar? <EHB 03Nov85>
- BLT.S ItsInDrag ; => if so, it's in drag <EHB 29Aug85>
- BTST #hasTallTBar,D6 ; does it have tall title bar? <JKC 31Jul89>
- BNE.S @4 ; => yes, test for big zoom <JKC 31Jul89>
- CMP.W #-17,D0 ; too far left for small zoom? <JKC 31Jul89>
- BLT.S ItsInDrag ; => if so, it's in drag <JKC 31Jul89>
- BRA.S @5 ; it's in small zoom <JKC 31Jul89>
-
- @4 CMP.W #-9,D0 ; too far right? <EHB 03Nov85>
- BGT.S ItsInDrag ; => if so, it's in drag <EHB 18Oct85>
-
- @5 BSR IsItSmall ; is window big? <EHB 29Aug85>
- BEQ.S @1 ; => oh boy, right again <EHB 29Aug85>
- MOVEQ #wInZoomOut,D0 ; say window small <EHB 29Aug85>
- BRA.S DoneHitDoc ; und scram-muller <EHB 29Aug85>
-
- @1 MOVEQ #wInZoomIn,D0 ; say window big <EHB 29Aug85>
- BRA.S DoneHitDoc ; and muller out of here <EHB 29Aug85>
-
- ItsInDrag MOVEQ #wInDrag,D0 ; flag in drag region
-
- DoneHitDoc MOVE.L D0,20(A6) ; update function result
-
- DoneHit1 RTS
-
-
- ; CalcDoc -- calculate the structure and content regions for the window pointed
- ; to by A3. First update size for zooming if necessary
-
- CalcDoc BSR IsThereZoom ; zoom feature enabled? <EHB 29Aug85>
- BEQ.S @1 ; => no <EHB 29Aug85>
- BSR IsItSmall ; update window size <EHB 29Aug85>
- @1
- LEA TEMPRECT,A0 ; get a pointer to the work rectangle
- MOVE.L A0,-(SP) ; push for later offset
- MOVE.L PORTRECT(A3),(A0)+ ; copy topLeft of portRect
- MOVE.L PORTRECT+4(A3),(A0) ; copy botLeft of portRect
-
- ; offset it to global coordinates
-
- MOVE.L A3,A0 ; convert the pointer if its a pixmap <C424/18Nov86> DAF
- BSR PortToMap ; convert <C424/18Nov86> DAF
- MOVE.L BOUNDS(A0),-(SP) ; push topLeft of port.portBits.bounds <C424/18Nov86> DAF
- NEG 0(SP) ; negate offset
- NEG 2(SP) ; both words
- _OffsetRect ; offset tempRect to global coordinates
-
- ; make the rectangular content region
-
- MOVE.L CONTRGN(A3),-(SP) ; content region gets the result
- PEA TempRect ; tempRect is the rectangle
- _RectRgn ; go make the region into content region
-
- ; now do the structure region. First correct the bounding rectangle (tempRect) for
- ; structure instead of content
-
- MOVE.L #$00020002,D4 ; get the shadow factor for DBox
- MOVE.L STRUCTRGN(A3),-(SP) ; push the structRgn for later
- PEA TEMPRECT ; push a pointer to the rect
- MOVE.L (SP),-(SP) ; make two copies
- MOVE.L MinusOne,-(SP) ; make 1 pixel bigger, all around
- _InsetRect ; make it bigger
-
- MOVE.W D7,D0 ; move up to top of window <29Aug85>
- SUBQ.W #1,D0 ; tweak it <5Aug85>
- SUB.W D0,TempRect+Top ; and set top of struct region <5Aug85>
-
- LSR.L #1,D4 ; adjust shadow factor
- CalcCommon
- _RectRgn ; RectRgn(structRgn,tempRect)
-
- ; now add in the 1 or 2 pixel drop shadow
-
- ;;The next block (marked with ";;") was commented out by Chris Knepper on 10-Oct-90
- ;; TST.B IsColor(A6) ; are we on a multi-bit Mac?
- ;; BEQ.S NormShadow ; if not, then do normal shadows
- ;;
- ;; ADD.L D4,TempRect+botright ; increase rect by shadow size
- ;; MOVE.L StructRgn(A3),-(SP) ; push the regionHandle
- ;; PEA TempRect ; and the rect
- ;; _RectRgn ; and set it
- ;; BRA.S CommShadow ; and continue
- ;;NormShadow
- ;;
- MOVE.L TempRgn(A6),-(SP) ; get temp region <EHB 18Oct85>
- PEA TempRect ; push tempRect
- MOVE.L (SP),-(SP) ; save another copy
- MOVE.L D4,-(SP) ; push shadow factor
- _OffsetRect ; offset it
- _RectRgn
-
- MOVE.L StructRgn(A3),-(SP)
- MOVE.L TempRgn(A6),-(SP) ; get temp region <EHB 18Oct85>
- MOVE.L StructRgn(A3),-(SP) ; structure gets the result
- _UnionRgn ; add it in
- CommShadow
-
- ; all done with CalcDocRgns
-
- NoDropShadow
- RTS
-
-
- ; GrowDoc handles the grow message by drawing a grow outline based on the rectangle
- ; passed in D3
-
- GrowDoc
-
- ; first make it one pixel bigger to jibe with the structure
-
- MOVE.L D3,-(SP) ; push the rect
- MOVE.L MinusOne,-(SP) ; push (-1,-1)
- _InsetRect
- MOVE.L D3,A3 ; get rect ptr
- MOVE.L Top(A3),-(SP) ; save topleft for below <5Aug85>
- MOVE.W D7,D0 ; adjust for title <29Aug85>
- SUB.W #1,D0 ; and tweak it <5Aug85>
- SUB.W D0,Top(A3) ; and save it <5Aug85>
-
- MOVE.L D3,-(SP) ; push the rectangle
- _FrameRect ; frame it
-
- ; now that the rectangle is drawn, draw the lower horizontal line
-
- MOVE.W Left(A3),-(SP) ; push left
- MOVE.W Bottom(A3),-(SP) ; push bottom
- SUB #16,(SP) ; really 16 pixels above bottom
- MOVE.L (SP),-(SP) ; make a copy of this point
- _MoveTo ; move to it
- MOVE.W Right(A3),2(SP) ; now go to the right edge
- _LineTo ; draw the horizontal line
-
- ; draw the upper horizontal line
-
- MOVE.L (SP),Top(A3) ; restore topLeft, leave on stack <5Aug85>
- MOVE.L (SP),-(SP) ; make a copy of this point
- _MoveTo ; move to it
- MOVE.W Right(A3),2(SP) ; now go to the right edge
- _LineTo ; draw the horizontal line
-
- ; draw the vertical line
-
- MOVE.W Right(A3),-(SP) ; push right
- SUB #16,(SP) ; really want right - 16
- MOVE.W Top(A3),-(SP) ; push top
- MOVE.L (SP),-(SP) ; make a copy of this point
- _MoveTo ; and move to it
- MOVE.W Bottom(A3),(SP) ; now go to bottom edge
- _LineTo ; draw the vertical line
-
- ; restore the rect back to how it was when we got it
-
- MOVE.L D3,-(SP) ; push the rect
- MOVE.L OneOne,-(SP) ; push (1,1)
- _InsetRect
- RTS ; all done!
-
- ; Utility PaintDropShadow -- drop shadows the rectangle in A4, by the amount in D4
-
- PaintDropShadow
- MOVE.L D4,-(SP) ; push shadow factor
- _PenSize ; make penSize = shadow factor
-
- MOVE RIGHT(A4),D0 ; get right of menuRect
- MOVE D0,-(SP) ; push right
- MOVE TOP(A4),-(SP) ; push top
- ; IF not SquareWind THEN ; <C203/06Oct86> DAF
- ADD D4,(SP) ; want top+shadow
- ; ENDIF ; <C203/06Oct86> DAF
- MOVE D0,-(SP) ; push right
- MOVE BOTTOM(A4),D0 ; get bottom
- MOVE D0,-(SP) ; push bottom
- MOVE LEFT(A4),-(SP) ; push left
- ; IF not SquareWind THEN ; <C203/06Oct86> DAF
- ADD D4,(SP) ; want left+shadow
- ; ENDIF ; <C203/06Oct86> DAF
- MOVE D0,-(SP) ; push bottom
-
- ;; TST.B IsColor(A6) ; are we on a multi-bit Mac?
- ;; BNE.S NOffSh ; if so, then don't offset shadow
- ;; TST.W D5 ;
- ;; BEQ.S NOffSh ;
-
- ; adjust shadow line ends
-
- ;; ADD D4,2(SP) ; want left+shadow
- ;; ADD D4,8(SP) ; want top+shadow
-
- NOffSh
-
- ; colors are OK here
-
- _MoveTo ; MoveTo(left+shadow,bottom)
- _LineTo ; LineTo(right,bottom)
- _LineTo ; LineTo(right,top+shadow)
-
- _PenNormal ; restore normal pen
- RTS
-
-
- ; PlotSymbol -- plot the little 16 by 16 symbol bitmap pointed to by A1 into the rectangle
- ; pointed held in TempRect. D0 holds the mode.
- ; Plot Symbol plots an 8 by 8 symbol if the window has a short title bar.
-
- PlotSymbol
- LEA IconBitMap,A0 ; get pointer to source bitmap
- MOVE.L A1,(A0)+ ; update base address of bitMap
- MOVE #2,(A0)+ ; update rowBytes
- CLR.L (A0)+ ; topLeft is zero, zero
- MOVE.L D1,(A0) ; adjust boundsRect
-
- ; push parameters for CopyBits call to transfer arrow bitMap
-
- PEA IconBitMap ; push pointer source bitmap
- MOVE.L (SP),A0 ; remember in A0, too
- MOVE.L GrafGlobals(A5),A1 ; get lisaGraf global baseaddress
- MOVE.L THEPORT(A1),A1 ; get thePort
- PEA PORTBITS(A1) ; that's the destination bitmap
-
- PEA BOUNDS(A0) ; boundsRect of bitmap is source
- PEA TempRect ; tempRect is the destination
- MOVE.W D0,-(SP) ; theMode is in D0
- CLR.L -(SP) ; no mask region
-
- ; the colors should be OK here <DAF 16-Apr-86>
-
- ; transfer the bitMap (stretching as necessary...)
-
- _CopyBits ; let Bill stretch those bits
-
- RTS ; return to caller
-
-
-
- ; Draw the grow icon. First make this window the current grafPort
-
- DrawGIcon
- MOVE.L GrafGlobals(A5),A0 ; get the current port and save it <C203> DAF
- MOVE.L thePort(A0),-(SP) ; <C203> DAF
-
- MOVE.L A3,-(SP) ; push the window's port
- _SetPort ; make that the port
-
-
- ; save the foreground and background of the user port & set new colors <DAF 16-Apr-86>
-
- TST.B IsColor(A6) ; is this a color system?
- BEQ.S @NoColor7 ; nope, so skip this stuff
-
- SUBQ #6,SP ; make room for rgbColor on stack <C???/11Jan87> DAF
- MOVE.L SP,-(SP) ; push pointer to placeholder <C???/11Jan87> DAF
- _GetForeColor ; get the window port's foreColor <C???/11Jan87> DAF
-
- SUBQ #6,SP ; make room for the backColor too <C???/11Jan87> DAF
- MOVE.L SP,-(SP) ; push pointer to placeholder <C???/11Jan87> DAF
- _GetBackColor ; get the window port's backColor <C???/11Jan87> DAF
-
- MOVE.W #wContentColor,D0 ; get the drawing color
- BSR SetUpColor ;
- _RGBBackColor ; <C117/25Sep86> DAF
-
- MOVE.W #wFrameColor,D0 ;
- BSR SetUpColor ;
- _RGBForeColor ; <C117/25Sep86> DAF
- @NoColor7 ; END OF COLOR-ONLY SECTION
-
- ; compute the grow icon rectangle in tempRect
-
- LEA TempRect,A4 ; get pointer to tempRect
- MOVE.L PortRect+4(A3),4(A4) ; copy in botRight of tempRect
- MOVE.L 4(A4),(A4) ; into the topLeft, too
- SUB.W #15,Top(A4)
- SUB.W #15,Left(A4) ; and left, too
-
- ; plot the grow icon
-
- TST.B wHilited(A3) ; is it hilited?
- BEQ.S ClearGoAway ; if not, go clear it
-
- LEA GrowBits,A1 ; get pointer to the bits
- MOVEQ #0,D0 ; use srcCopy
- MOVE.L #$00100010,D1
- BSR PlotSymbol ; plot it
-
- ; plot the boundary lines
-
- PlotBoundary
- MOVE.W Left(A4),-(SP) ; push tempRect.left
- MOVE.W (SP),-(SP) ; copy it again for later
- MOVE PortRect+Top(A3),-(SP) ; push portRect.top
- _MoveTo ; move to it
- MOVE PortRect+Bottom(A3),-(SP) ; push portRect.bottom
- _LineTo ; draw the vertical line
-
- ; now draw the horizontal line
-
- MOVE.W PortRect+Left(A3),-(SP) ; push portRect.left
- MOVE.W Top(A4),-(SP) ; push tempRect.top
- _MoveTo
- MOVE.W PortRect+right(A3),-(SP) ; push portRect.right
- MOVE.W Top(A4),-(SP) ; push tempRect.top
- _LineTo
-
- ; all done with DrawDocGrow
-
- DoneDDG
- TST.B IsColor(A6) ; is it a color system?
- BEQ.S @NoColor8 ; no, so skip this restore
-
- MOVE.L SP,-(SP) ; push ptr to rgbColor previously saved on top of stack <C117/25Sep86> DAF
- _RGBBackColor ; <C117/25Sep86> DAF
- ADDQ #6,SP ; trash backcolor <C117/25Sep86> DAF
- MOVE.L SP,-(SP) ; <C117/25Sep86> DAF
- _RGBForeColor ; <C117/25Sep86> DAF
- ADDQ #6,SP ; <C117/25Sep86> DAF
- @NoColor8 ; END OF A COLOR-ONLY SECTION
-
- _SetPort ; restore the incoming port (saved above) <C203> DAF
-
- RTS
-
- ClearGoAway
- PEA TempRect
- _EraseRect
- BRA.S PlotBoundary
-
-
- ; BitMap for GrowIcon
-
- GrowBits
- DC.W $0000,$0000,$0000,$1FE0
- DC.W $1020,$103E,$1022,$1022
- DC.W $1022,$1022,$1FE2,$0402
- DC.W $0402,$0402,$07FE,$0000
-
- END
-
- ; end of Window DefProc #3